/* 
 * This code contains copyright information which is the proprietary property of
 * hotels.com. No part of this code may be reproduced, stored or transmitted in
 * any form without the prior written permission of hotels.com.   
 * Copyright (C) hotels.com. 2006 
 * All rights reserved.
 */

package com.txtsqlclient.dataaccess.database;

/**
 * @author spadda
 * @version $Revision: 1.2 $($Author: kchakr $ / $Date: 2006/05/30 12:18:24 $)
 */
public enum DatabaseType {

    /** MySQL with mysql-connector driver. */
    MYSQL("mysql", "com.mysql.jdbc.Driver", "jdbc:mysql://{ip}/{database}"),

    /** Microsoft SQL Server with jTDS driver. */
    SQL_SERVER("sql-server", "net.sourceforge.jtds.jdbc.Driver",
            "jdbc:jtds:sqlserver://{ip}/{database}");

    /** Identifier. */
    private String identifier;

    /** Class name of the Driver. */
    private String driverClassName;

    /** URL format for the connection. */
    private String connectionURL;

    private DatabaseType(String identifier, String driverClassName, String connectionURL) {
        this.identifier = identifier;
        this.driverClassName = driverClassName;
        this.connectionURL = connectionURL;
    }

    /**
     * This method is required to get the database type, based on the identifier.
     * 
     * @param identifier
     * @return
     */
    public static DatabaseType getDatabaseType(String identifier) {
        if (MYSQL.getIdentifier().equals(identifier)) {
            return MYSQL;
        } else if (SQL_SERVER.getIdentifier().equals(identifier)) {
            return SQL_SERVER;
        }
        return null;
    }

    /**
     * @return Returns the connectionURL.
     */
    public String getConnectionURL() {
        return this.connectionURL;
    }

    /**
     * @param connectionURL
     *            The connectionURL to set.
     */
    public void setConnectionURL(String connectionURL) {
        this.connectionURL = connectionURL;
    }

    /**
     * @return Returns the driverClassName.
     */
    public String getDriverClassName() {
        return this.driverClassName;
    }

    /**
     * @param driverClassName
     *            The driverClassName to set.
     */
    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }

    /**
     * @return Returns the identifier.
     */
    public String getIdentifier() {
        return this.identifier;
    }

    /**
     * @param identifier
     *            The identifier to set.
     */
    public void setIdentifier(String identifier) {
        this.identifier = identifier;
    }
}
